package com.admin.domain.modle;

import java.io.Serializable;

public class AjaxResponse implements Serializable {

    private static final long serialVersionUID = -2792556188993845048L;

    private int code;
    private String msg;
    private Object data;

    private AjaxResponse(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static AjaxResponse success() {
        return success("");
    }

    public static AjaxResponse success(String msg) {
        return success(msg, null);
    }

    public static AjaxResponse success(Object data) {
        return success("OK", data);
    }

    public static AjaxResponse success(String msg, Object data) {
        return get(0, msg, data);
    }

    public static AjaxResponse error() {
        return error("");
    }

    public static AjaxResponse error(String msg) {
        return error(-1, msg);
    }

    public static AjaxResponse error(int code, String msg) {
        return get(code, msg, null);
    }

    public static AjaxResponse get(int code, String msg, Object data) {
        return new AjaxResponse(code, msg, data);
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public Object getData() {
        return data;
    }

    @Override
    public String toString() {
        return "AjaxResponse [code=" + code + ", msg=" + msg + ", data=" + data
                + "]";
    }
}
